package com.cencat.merchant.entity;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;

/**
 * 派单规则实体类
 * 
 * @author cencat
 * @since 2024
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("biz_dispatch_rule")
public class DispatchRuleEntity {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 租户ID
     */
    @NotNull(message = "租户ID不能为空")
    @TableField("tenant_id")
    private Long tenantId;
    
    /**
     * 规则名称
     */
    @NotBlank(message = "规则名称不能为空")
    @Size(max = 100, message = "规则名称长度不能超过100个字符")
    @TableField("rule_name")
    private String ruleName;
    
    /**
     * 规则编码
     */
    @NotBlank(message = "规则编码不能为空")
    @Size(max = 50, message = "规则编码长度不能超过50个字符")
    @TableField("rule_code")
    private String ruleCode;
    
    /**
     * 规则类型(1-距离优先,2-评分优先,3-负载均衡,4-专属绑定)
     */
    @NotNull(message = "规则类型不能为空")
    @Min(value = 1, message = "规则类型值无效")
    @Max(value = 4, message = "规则类型值无效")
    @TableField("rule_type")
    private Integer ruleType;
    
    /**
     * 规则内容(JSON格式)
     */
    @NotBlank(message = "规则内容不能为空")
    @TableField("rule_content")
    private String ruleContent;
    
    /**
     * 规则优先级(数字越小优先级越高)
     */
    @NotNull(message = "规则优先级不能为空")
    @Min(value = 0, message = "规则优先级不能为负数")
    @TableField("priority")
    private Integer priority;
    
    /**
     * 规则状态(0-禁用,1-启用)
     */
    @NotNull(message = "规则状态不能为空")
    @Min(value = 0, message = "规则状态值无效")
    @Max(value = 1, message = "规则状态值无效")
    @TableField("rule_status")
    private Integer ruleStatus;
    
    /**
     * 适用商家类型(0-全部,1-S级,2-A级,3-B级)
     */
    @Min(value = 0, message = "适用商家类型值无效")
    @Max(value = 3, message = "适用商家类型值无效")
    @TableField("merchant_type")
    private Integer merchantType;
    
    /**
     * 适用时间段(JSON格式)
     */
    @TableField("time_range")
    private String timeRange;
    
    /**
     * 最大派单距离(公里)
     */
    @DecimalMin(value = "0.0", message = "最大派单距离不能为负数")
    @TableField("max_distance")
    private java.math.BigDecimal maxDistance;
    
    /**
     * 最小司机评分
     */
    @DecimalMin(value = "1.0", message = "最小司机评分不能低于1分")
    @DecimalMax(value = "5.0", message = "最小司机评分不能高于5分")
    @TableField("min_driver_rating")
    private java.math.BigDecimal minDriverRating;
    
    /**
     * 规则描述
     */
    @Size(max = 500, message = "规则描述长度不能超过500个字符")
    @TableField("rule_description")
    private String ruleDescription;
    
    /**
     * 生效开始时间
     */
    @TableField("effective_start_time")
    private LocalDateTime effectiveStartTime;
    
    /**
     * 生效结束时间
     */
    @TableField("effective_end_time")
    private LocalDateTime effectiveEndTime;
    
    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    /**
     * 创建人
     */
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private Long createBy;
    
    /**
     * 更新人
     */
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    private Long updateBy;
    
    /**
     * 逻辑删除标识(0-未删除,1-已删除)
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
}